package com.icode.core.shared;

import com.icode.core.model.house.HouseBaseArea;
import com.icode.core.model.house.HouseBaseTheme;
import com.icode.core.model.house.ProductType;

/**
 * Created with IntelliJ IDEA.
 * User: lb
 * Date: 15-11-19
 * Time: 上午9:52
 * To change this template use File | Settings | File Templates.
 */
public class RentHandle {

    public static String[] initThemes(String theme) {
        String[] themes = theme.split(",");
        for (int i = 0; i < themes.length; i++) {
            switch (themes[i]) {
                case "高尔夫":
                    themes[i] = "GAOERFU";
                    break;
                case "沙滩":
                    themes[i] = "SHATAN";
                    break;
                case "湖景":
                    themes[i] = "HUJING";
                    break;
                case "雪山":
                    themes[i] = "XUESHAN";
                    break;
                case "古镇":
                    themes[i] = "GUZHEN";
                    break;
                case "避寒":
                    themes[i] = "BIHAN";
                    break;
                case "避暑":
                    themes[i] = "BISHU";
                    break;
                case "温泉":
                    themes[i] = "WENQUAN";
                    break;
            }
        }
        return themes;
    }

    public static String initAreaHql(String area) {
        switch (area) {
            case "请选择目的地和城市":
                area = "";
                break;
            case "不限":
                area = "";
                break;
            case "三亚":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.SANYA + "'";
                break;
            case "苏州":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.SUZHOU + "'";
                break;
            case "丽江":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.LIJIANG + "'";
                break;
            case "西双版纳":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.XISHUANGBANNA + "'";
                break;
            case "深圳":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.SHENZHEN + "'";
                break;
            case "广州":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.GUANGZHOU + "'";
                break;
            case "成都":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.CHENGDU + "'";
                break;
            case "昆明":
                area = " and a.myHouse.houseInfo.buildingType.houseBase.houseBaseArea='" + HouseBaseArea.KUNMING + "'";
                break;
        }
        return area;
    }

    public static String initPriceHql(String price) {
        if (price.equals(" 不限") || price.equals("")) {
            price = "";
        } else {
            int price_temp = Integer.valueOf(price);
            int price_up = price_temp + 100;
            int price_lo = price_temp - 100;
            if (price_lo < 0) {
                price_lo = 0;
            }
            price = " and a.price>=" + price_lo + " and a.price<=" + price_up;
        }
        return price;
    }

    public static String initThemeHql(String theme) {
        switch (theme) {
            case "请选择主题风格":
                theme = "";
                break;
            case "不限":
                theme = "";
                break;
            case "高尔夫":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.GAOERFU + "%'";
                break;
            case "沙滩":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.SHATAN + "%'";
                break;
            case "湖景":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.HUJING + "%'";
                break;
            case "雪山":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.XUESHAN + "%'";
                break;
            case "古镇":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.GUZHEN + "%'";
                break;
            case "避寒":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.BIHAN + "%'";
                break;
            case "避暑":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.BISHU + "%'";
                break;
            case "温泉":
                theme = " and a.myHouse.houseInfo.buildingType.houseBase.themes like '%" + HouseBaseTheme.WENQUAN + "%'";
                break;
        }
        return theme;
    }

    public static ProductType initProductType(String productType) {
        switch (productType) {
            case "HOUSEBASE":
                return ProductType.HOUSEBASE;
            case "APARTMENT":
                return ProductType.APARTMENT;
            default:
                return null;
        }
    }
}
